<!DOCTYPE html>

<html>

<head>

    <!-- 页面meta -->

    <meta charset="utf-8">

    <meta http-equiv="X-UA-Compatible" content="IE=edge">

    <title>学生名单主页</title>

    <meta content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no" name="viewport">

    <!-- 引入样式 -->

    <link rel="stylesheet" href="../plugins/elementui/index.css">

    <link rel="stylesheet" href="../plugins/font-awesome/css/font-awesome.min.css">

    <link rel="stylesheet" href="../css/style.css">

</head>

<body class="hold-transition">

<div id="app">


    <div class="app-container">

        <center>
            <el-button type="primary" plain @click="myself">宿舍人员信息</el-button>
            <el-button type="primary" plain @click="leaves">请假</el-button>
            <el-button type="primary" plain @click="helperCheck">去查寝</el-button>
            <el-button type="primary" plain @click="checkDorm">我的查寝信息</el-button>
            <el-button type="primary" plain @click="checknotice">查看通告</el-button>
            <el-button type="warning" plain @click="ps">修改密码</el-button>
            <el-button type="danger" plain @click="tc">退出登陆</el-button>
        </center>
        <center>
            <el-table
                    :data="tableData"
                    style="width: 50%">

                <el-table-column
                        prop="sname"
                        label="姓名"
                        width="180">
                </el-table-column>

                <el-table-column
                        prop="phone"
                        label="电话"
                        width="180">
                </el-table-column>

                <el-table-column
                        prop="profession"
                        label="专业">
                </el-table-column>

            </el-table>

        </center>


    </div>

<!--    修改密码-->
    <div class="add-form">

        <el-dialog title="修改信息" :visible.sync="dialogFormVisible4Edit">

            <el-form ref="dataAddForm" :model="studentsDto"  label-position="right" label-width="100px">

                <el-row>


                    <el-col :span="12">

                        <el-form-item label="原密码" >

                            <el-input v-model="studentsDto.oldPassword"/>

                        </el-form-item>

                    </el-col>
                    <el-col :span="12">

                        <el-form-item label="新密码" >

                            <el-input v-model="studentsDto.newPassword"/>

                        </el-form-item>

                    </el-col>

                    <el-col :span="12">

                        <el-form-item label="确认新密码" >

                            <el-input v-model="studentsDto.newPassword2"/>

                        </el-form-item>

                    </el-col>




                </el-row>




            </el-form>

            <div slot="footer" class="dialog-footer">

                <el-button @click="cancel()">取消</el-button>

                <el-button type="primary" @click="handleEdit()">确定</el-button>

            </div>

        </el-dialog>

    </div>

</div>

</body>

<!-- 引入组件库 -->

<script src="../js/vue.js"></script>

<script src="../plugins/elementui/index.js"></script>

<script type="text/javascript" src="../js/jquery.min.js"></script>

<script src="../js/axios-0.18.0.js"></script>

<script>
    var vue = new Vue({
        el: '#app',
        data: {
            tableData: [],
            dialogFormVisible4Edit:false,
            studentsDto:{
                oldPassword:undefined,
                newPassword:undefined,
                newPassword2:undefined
            }
        },

        //钩子函数，VUE对象初始化完成后自动执行
        mounted() {
            this.getAll();
        },

        methods: {
            //列表
            getAll() {
                axios.get("http://localhost/dormitory/searchDorm").then((res) => {
                    if (res.data.errMsg == '请先登陆') {
                        this.$message.error(res.data.errMsg);
                        window.location.href = '/xu/pages/studentLogin.html'
                    }
                    this.tableData = res.data.data
                })

            },
            tc() {
                this.$confirm("确定退出账户？","提示",{type:"info"}).then(()=>{
                    axios.post("http://localhost/logout").then((res)=>{
                        window.location.href = '/xu/pages/studentLogin.html'
                    })
                })
            },
            ps(){
                this.dialogFormVisible4Edit=true;

            },
            cancel(){
                this.dialogFormVisible4Edit=false;
            },
            handleEdit(){
                axios.post("http://localhost/updatePassword",this.studentsDto).then((res)=>{
                    if (res.data.errMsg!=null){
                        this.$message.error(res.data.errMsg);
                        return;
                    }
                    window.location.href = '/xu/pages/studentLogin.html'
                })
            },
            leaves(){
                window.location.href="http://localhost:80/wu/pages/studentLeave.html"
            },
            myself(){
                window.location.href="http://localhost:80/xu/pages/myself.html"
            },
            checknotice(){
                window.location.href="http://localhost:80/xu/pages/stuboard.html"
            },
            checkDorm(){
                window.location.href="http://localhost:80/wu/pages/studentCheckDorm.html"
            },
            helperCheck(){
                window.location.href="http://localhost:80/wu/pages/helperCheck.html"
            }
        }
    })

</script>

</html>